﻿Public Class NhanVien2
    Private data As New DataTable
    Private xlnv As XLNhanVien
    Public ds As New ArrayList
    Private Sub NhanVien2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        xlnv = New XLNhanVien
        data = xlnv.BUS_LayDSNV()
        If data.Rows.Count < 0 Then Return
        lv_nhanvien.Items.Clear()
        lv_nhanvien.View = View.Details
        lv_nhanvien.GridLines = True
        lv_nhanvien.FullRowSelect = True
        For Each dr As DataRow In data.Rows
            Dim item As New ListViewItem
            item.Text = "STT"
            item.SubItems.Add(dr("MaNV"))
            item.SubItems.Add(dr("HoTen"))
            item.SubItems.Add(dr("NgaySinh"))
            item.SubItems.Add(dr("GioiTinh"))
            item.SubItems.Add(dr("NoiSinh"))
            item.SubItems.Add(dr("NguyenQuan"))
            item.SubItems.Add(dr("CMND"))
            item.SubItems.Add(dr("NgayCap"))
            item.SubItems.Add(dr("NoiCap"))
            item.SubItems.Add(dr("DienThoai"))
            item.SubItems.Add(dr("DCTTru"))
            item.SubItems.Add(dr("DanToc"))
            item.SubItems.Add(Convert.ToString(dr("TonGiao")))
            item.SubItems.Add(dr("TrinhDoHocVan"))
            item.SubItems.Add(dr("BangCap"))
            item.SubItems.Add(dr("CVu"))
            item.SubItems.Add(dr("QTich"))
            item.SubItems.Add(dr("NgoaiNgu"))
            item.SubItems.Add(Convert.ToString(dr("Doan")))
            item.SubItems.Add(Convert.ToString(dr("Dang")))
            item.SubItems.Add(Convert.ToString(dr("TTBThan")))
            item.SubItems.Add(dr("MaPhong"))
            item.SubItems.Add(dr("Hinh"))
            lv_nhanvien.Items.Add(item)
            capnhatSTT()
        Next
    End Sub
    Private Sub capnhatSTT()
        For i As Integer = 1 To lv_nhanvien.Items.Count
            lv_nhanvien.Items(i - 1).Text = i.ToString
        Next
    End Sub

    Private Sub lv_nhanvien_SelectedIndexChanged_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lv_nhanvien.SelectedIndexChanged
        If data.Rows.Count < 0 Then
        Else
            'Dim lvds As Windows.Forms.TextBox = Me.Tag
            If PhongBan.st = True Then
                PhongBan.tb_truongphong.Text = lv_nhanvien.SelectedItems(0).SubItems(2).Text()
                PhongBan.manv = lv_nhanvien.SelectedItems(0).SubItems(1).Text()
            Else
                Dim nv As New DTO_NhanVienCT.NhanVien
                nv.MaNV = lv_nhanvien.SelectedItems(0).SubItems(1).Text()
                nv.HoTen = lv_nhanvien.SelectedItems(0).SubItems(2).Text()
                nv.QuocTich = lv_nhanvien.SelectedItems(0).SubItems(17).Text()
                nv.ChucVu = lv_nhanvien.SelectedItems(0).SubItems(16).Text()
                nv.DiaChi = lv_nhanvien.SelectedItems(0).SubItems(11).Text()
                nv.DienThoai = lv_nhanvien.SelectedItems(0).SubItems(10).Text()
                ds.Add(nv)
            End If
            Me.Close()
        End If
    End Sub
End Class